﻿////==============================================================================  
////Copyright (C) 2012-2015 9UN.ORG. All rights reserved. 
////GUID：46172595-6b69-4526-b9da-426d663f5b05
////CLR Version: 4.0.30319.18033
////Code Author：Kevin Wang
////Contact：Email(Admin@9un.org),QQ(265382 or 74344)
////Filename：DisposingRequiredObjectBase
////Namespace：RuanRang.Media.Core.Common
////Functions：DisposingRequiredObjectBase  
////Created by Kevin Wang at 2013/2/2 23:05:09 http://blog.9un.org
////============================================================================== 

//#region Usings

//using System;
//using System.Diagnostics;

//#endregion

//namespace RuanRang.Media.Core.Common
//{
//    /// <summary>
//    /// Base class for types requires necessary Dispose() call after using instance of type.
//    /// </summary>
//    public class DisposingRequiredObjectBase : IDisposable
//    {
//        private bool _isDisposed;
//        /// <summary>
//        /// Is object already disposed.
//        /// </summary>
//        public bool IsDisposed
//        {
//            get
//            {
//                return (_isDisposed);
//            }
//            set { (_isDisposed) = value; }
//        }

//        /// <summary>
//        /// Verifies that object was not disposed.
//        /// If disposed, <see cref="ObjectDisposedException"/> will be thrown.
//        /// </summary>
//        protected void VerifyObjectIsNotDisposed()
//        {
//            if (_isDisposed)
//            {
//                throw new ObjectDisposedException(ToString(), String.Format("This instance of {0} has been already disposed.", GetType()));
//            }
//        }

//        /// <summary>
//        /// Overridable method for release allocated resources from the derived types.
//        /// </summary>
//        /// <param name="isDisposing">isDisposing is True if using a determined destruction, False if called from finalizer.</param>
//        protected virtual void Dispose(bool isDisposing)
//        {

//        }

//        /// <summary>
//        /// Cleanup all.
//        /// </summary>
//        public virtual void Dispose()
//        {
//            if (_isDisposed) return;
//            _isDisposed = true;
//            //
//            Dispose(true);
//            GC.SuppressFinalize(this);
//        }


//        /// <summary>
//        /// Debug-style finalizer.
//        /// </summary>
//        ~DisposingRequiredObjectBase()
//        {
//#if DEBUG
//            Debugger.Log(0, Debugger.DefaultCategory, String.Format("Finalizer of {0} has been called. The object has not been disposed correctly.\n", GetType()));
//#endif
//            //
//            if (!_isDisposed)
//            {
//                // NOTE : you can ban the finalizer call if comment next statement
//                Dispose(false);
//            }
//        }
//    }
//}